package com.example.http.utils;

import com.example.http.HttpUtils;

/**
 * @author jingbin
 * @data 2018/2/9
 * @Description
 */

public class BuildFactory {

//    private static BuildFactory instance;
    private volatile static BuildFactory instance; //声明成 volatile
    private BuildFactory (){}

    private Object videoHttps;

    public static BuildFactory getInstance() {
        if (instance == null) {
            synchronized (BuildFactory.class) {
                if (instance == null) {
                    instance = new BuildFactory();
                }
            }
        }
        return instance;
    }

    public <T> T create(Class<T> a, String type) {
        if (videoHttps == null) {
            synchronized (BuildFactory.class) {
                if (videoHttps == null) {
                    videoHttps = HttpUtils.getInstance().getBuilder(type).build().create(a);
                }
            }
        }
        return (T) videoHttps;
    }
}
